<% content_for :content do %>

  <!-- widget grid -->
  <section id="widget-grid" class="">
  
    <!-- row -->
    <div class="row">
  
      <!-- NEW WIDGET START -->
      <article class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
  
        <!-- Widget ID (each widget will need unique ID)-->
        <div class="jarviswidget jarviswidget-color-blueDark" id="wid-id-3" data-widget-editbutton="false" data-widget-colorbutton="false" data-widget-deletebutton="false">
          <!-- widget options:
          usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">
  
          data-widget-colorbutton="false"
          data-widget-editbutton="false"
          data-widget-togglebutton="false"
          data-widget-deletebutton="false"
          data-widget-fullscreenbutton="false"
          data-widget-custombutton="false"
          data-widget-collapsed="true"
          data-widget-sortable="false"
  
          -->
          <header>
            <span class="widget-icon"> <i class="fa fa-table"></i> </span>
            <h2>用户列表</h2>
          </header>
  
          <!-- widget div-->
          <div>
  
            <!-- widget edit box -->
            <div class="jarviswidget-editbox">
              <!-- This area used as dropdown edit box -->
  
            </div>
            <!-- end widget edit box -->
  
            <!-- widget content -->
            <div class="widget-body no-padding">
              <div class="widget-body-toolbar">
                
              </div>
              <table id="datatable_tabletools" class="table table-striped table-hover vertical-align-middle">
                <thead>
                  <tr>
                    <th>ID</th>
                    <th>邮箱</th>
                    <th>分组管理</th>
                    <th>区域管理</th>
                    <th>操作</th>
                  </tr>
                </thead>
                <tbody>
                <% @users.each do |u| %>
                  <tr id="user-<%= u.id %>">
                    <td>
                      <%= u.id %>
                    </td>
                    <td>
                      <%= u.email %>
                    </td>
                    <td>
                      <%= link_to u.group_names, edit_admin_admin_path(u), remote: true %>
                    </td>
                    <td><%= link_to "区域管理",zone_admin_admin_path(u) if current_admin.can?(controller: "admin/admin", action: "zone") if current_admin.god? %></td>
                    <td>
                      <%= link_to "修改密码", edit_password_admin_admin_path(u), remote: true %>
                    </td>
                  </tr>
                <% end %>
                </tbody>
              </table>
  
            </div>
            <!-- end widget content -->
  
          </div>
          <!-- end widget div -->
  
        </div>
        <!-- end widget -->
  
      </article>
      <!-- WIDGET END -->
  
    </div>
  
    <!-- end row -->
  
  </section>
  <!-- end widget grid -->
<% end %>

<% content_for :js do %>

  <script type="text/javascript">
  
    $(document).ready(function() {
      
      /* TABLE TOOLS */
      $('#datatable_tabletools').dataTable({
        "sDom" : "<'dt-top-row'Tlf>r<'dt-wrapper't><'dt-row dt-bottom-row'<'row'<'col-sm-6'i><'col-sm-6 text-right'p>>",
        "oTableTools" : {
          "aButtons" : [ 
              {
                "sExtends":    "text",
                "sButtonText": '<%= link_to("添加管理员", new_admin_admin_path, :remote => true) if current_admin.can?(controller: "admin/admin", action: "new") %>'
              }
           ],
        },
        "bInfo": true,
        "fnInitComplete" : function(oSettings, json) {
          $(this).closest('#dt_table_tools_wrapper').find('.DTTT.btn-group').addClass('table_tools_group').children('a.btn').each(function() {
            $(this).addClass('btn-sm btn-default');
          });
        }
      });

    })

  </script>
<% end %>